<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>用户管理</title>
    <link rel="shortcut icon" th:href="@{/img/favicon.ico}"/>
    <link rel="bookmark" th:href="@{/img/favicon.ico}" type="image/x-icon"/>
    <link th:href="@{/css/style.css}" rel="stylesheet" type="text/css"/>
    <script type="text/javascript" th:src="@{/js/jquery.js}"></script>
    <script type="text/javascript">
        function tipOpen(ele) {
            $(".tipright p").text("您确定要修改此员工吗?");
            $("#tip").fadeIn(200);
            var uid = $(ele).prev().val();
            $("#uid2").val(uid);
        }

        function tipClose() {
            $("#tip").fadeOut(200);
        }

        function yes() {
            $("#tip").fadeOut(200);
            var uid = $("#uid2").val();
            window.location.href="/sys/users/updateStatus?uId="+uid;
        }
        function warning(ele) {
            $(".tipright p").text("请先启用该用户所在职位！");
            $("#tip2").fadeIn(200);
        }
        function tipClose2() {
            $("#tip2").fadeOut(200);
            alert("111111")
        }
    </script>
</head>

<body>
<div class="place"><span>位置：</span>
    <ul class="placeul">
        <li>系统管理</li>
        <li>用户管理</li>
    </ul>
</div>
<div class="rightinfo">
    <form id="usersForm" th:action="@{/sys/users/findByPage}" method="post">
        <input type="hidden" name="pageno" id="pageno"/>
        <ul class="tools">
            <li><label>员工编号:</label>
                <input type="text" name="uId" th:value="${user.uId}"/>
            </li>
            <li><label>员工姓名:</label>
                <input type="text" name="uname" th:value="${user.uname}"/>
            </li>
            <li><label>所属部门：</label>
                <select name="deptId">
                    <option value="0">请选择部门</option>
                    <option th:each="d : ${session.dlist}" th:value="${d.deptId}" th:text="${d.deptName}"
                    th:selected="${d.deptId==user.deptId?'true':'false'}"></option>
                </select>
            </li>
            <li><label>状态：</label>
                <select name="statusId">
                    <option value="0">请选择</option>
                    <option value="1" th:selected="${user.statusId==1}?'true':'false'">在职</option>
                    <option value="2" th:selected="${user.statusId==2}?'true':'false'">离职</option>
                </select>
            </li>
            <li class="subBut" onclick="Search(1)"><img th:src="@{/images/t06.png}"/>查询</li>
            <li class="subBut" onclick="window.location.href='/sys/users/userAdd.html'"><img th:src="@{/images/t01.png}"/>添加</li>
        </ul>
        <table class="tablelist">
            <thead>
            <tr>
                <th>序号</th>
                <th>员工编号</th>
                <th>员工姓名</th>
                <th>联系电话</th>
                <th>所属部门</th>
                <th>职位</th>
                <th>性别</th>
                <th>年龄</th>
                <th>状态</th>
                <th>入职时间</th>
                <th>离职时间</th>
                <th>操作</th>
            </tr>
            </thead>
            <tbody>
            <tr th:each="u,var : ${pageInfo.records}">
                <td th:text="${(pageInfo.current-1)*pageInfo.size+var.count}"></td>
                <td th:text="${u.uId}"></td>
                <td th:text="${u.uname}"></td>
                <td th:text="${u.utelephone}"></td>
                <td th:text="${u.deptId==null?'':u.dept.deptName}"></td>
                <td th:text="${u.jobId==null?'':u.job.jobName}"></td>
                <td th:text="${u.sex==1?'男':'女'}"></td>
                <td th:text="${u.age}"></td>
                <td th:text="${u.statusId==1?'在职':'离职'}"></td>
                <td th:text="${#dates.format(u.hiredate,'yyyy-MM-dd')}"></td>
                <td th:text="${#dates.format(u.leavedate,'yyyy-MM-dd')}"></td>
                <td>
                    <a th:if="${session.users.jobId==1||(session.users.jobId==9&&u.jobId!=1)}" th:href="@{'/sys/users/goUpdate?uId='+${u.uId}+'&jobId='+${u.jobId}}" class="tablelink">修改</a>
                    <input type="hidden" th:value="${u.uId}" />
                    <a href="javascript:void(0);" th:if="${u.job.jobState=='1'&&(session.users.jobId==1||(session.users.jobId==9&&u.jobId!=1))}" th:text="${u.statusId==1?'离职':'复职'}" class="tablelink" onclick="tipOpen(this)">注销</a>
                    <a href="javascript:void(0);" th:if="${u.job.jobState=='2'&&(session.users.jobId==1||(session.users.jobId==9&&u.jobId!=1))}" th:text="${u.statusId==1?'离职':'复职'}" class="tablelink" onclick="warning(this)">注销</a>
                </td>
            </tr>
            </tbody>
        </table>
        <div class="pagin">
            <div class="message">共<i class="blue" th:text="${pageInfo.total}">1256</i>条记录，当前显示第&nbsp;<i class="blue" th:text="${pageInfo.current}">2&nbsp;</i>页
            </div>
            <ul class="paginList">
                <li class="paginItem">
                    <a href="javascript:void(0);" th:onclick="Search([[${pageInfo.hasPrevious()?pageInfo.current-1:1}]])">
                        <span th:class="${pageInfo.hasPrevious()?'pagenxt roate':'pagepre'}"></span>
                    </a>
                </li>
                <li class="paginItem" th:if="${1+4<=pageInfo.current}">
                    <a th:onclick="Search(1)" href="javascript:void(0);">1</a>
                </li>
                <li class="paginItem more" th:if="${1+5<=pageInfo.current}">
                    <a href="javascript:void(0);">...</a>
                </li>
                <li class="paginItem" th:if="${1+3<=pageInfo.current}">
                    <a th:onclick="Search([[${pageInfo.current-3}]])" href="javascript:void(0);" th:text="${pageInfo.current-3}">3</a>
                </li>
                <li class="paginItem" th:if="${1+2<=pageInfo.current}">
                    <a th:onclick="Search([[${pageInfo.current-2}]])" href="javascript:void(0);" th:text="${pageInfo.current-2}">4</a>
                </li>
                <li class="paginItem" th:if="${1+1<=pageInfo.current}">
                    <a th:onclick="Search([[${pageInfo.current-1}]])" href="javascript:void(0);" th:text="${pageInfo.current-1}">1</a>
                </li>
                <li class="paginItem current">
                    <a href="javascript:void(0);" th:text="${pageInfo.current}">2</a>
                </li>
                <li class="paginItem" th:if="${pageInfo.pages-1>=pageInfo.current}">
                    <a th:onclick="Search([[${pageInfo.current+1}]])" href="javascript:void(0);" th:text="${pageInfo.current+1}">3</a>
                </li>
                <li class="paginItem" th:if="${pageInfo.pages-2>=pageInfo.current}">
                    <a th:onclick="Search([[${pageInfo.current+2}]])" href="javascript:void(0);" th:text="${pageInfo.current+2}">4</a>
                </li>
                <li class="paginItem" th:if="${pageInfo.pages-3>=pageInfo.current}">
                    <a th:onclick="Search([[${pageInfo.current+3}]])" href="javascript:void(0);" th:text="${pageInfo.current+3}">5</a>
                </li>
                <li class="paginItem more" th:if="${pageInfo.pages-5>=pageInfo.current}">
                    <a href="javascript:void(0);">...</a>
                </li>
                <li class="paginItem" th:if="${pageInfo.pages-4>=pageInfo.current}">
                    <a th:onclick="Search([[${pageInfo.pages}]])" href="javascript:void(0);" th:text="${pageInfo.pages}">10</a>
                </li>
                <li class="paginItem">
                    <a href="javascript:void(0);" th:onclick="Search([[${pageInfo.hasNext()?pageInfo.current+1:pageInfo.pages}]])">
                        <span th:class="${pageInfo.hasNext()?'pagenxt':'pagepre roate'}"></span>
                    </a>
                </li>
            </ul>
        </div>
    </form>
    <script>
        function Search(current) {
            $("#pageno").val(current);
            $("#usersForm").submit();
        }
    </script>
    <!-- 提示框 -->
    <div id="tip" class="tip">
        <div class="tiptop"><span>提示信息</span><a onclick="tipClose()"></a></div>
        <div class="tipinfo"><span><img th:src="@{/images/ticon.png}"/></span>
            <div class="tipright">
                <p></p>
                <cite>如果是请点击确定按钮 ，否则请点取消。</cite></div>
        </div>
        <input type="hidden" id="uid2"   />
        <div class="tipageInfotn" style="text-align: center;">
            <input name="" type="button" class="sure" value="确定" onclick="yes()"/>
            &nbsp;
            <input name="" type="button" class="cancel" value="取消" onclick="tipClose()"/>
        </div>
    </div>

    <!-- 提示框2 -->
    <div id="tip2" class="tip">
        <div class="tiptop"><span>提示信息</span><a onclick="tipClose2()"></a></div>
        <div class="tipinfo"> <span><img th:src="@{/images/ticon.png}" /></span>
            <div class="tipright">
                <p></p>
                <cite></cite> </div>
        </div>
        <div class="tipbtn">
            <input name="" type="button"  class="sure" value="确定" onclick="tipClose2()" />
            &nbsp;
            <input name="" type="button"  class="cancel" value="取消" onclick="tipClose2()" />
        </div>
    </div>
</div>
<script type="text/javascript">
    $('.tablelist tbody tr:odd').addClass('odd');
    //submit提交
</script>
</body>
</html>
